pub fn time_info(time: &str) -> String {
    let date = Date::from(time);
    let week = date.get_the_week();
    let days_left_this_year = date.get_days_before_end();
    let this_year_spring_festival = Date::get_the_year_spring_festival(date.year);
    let spring_days = if date.month < this_year_spring_festival.month
        || (date.month == this_year_spring_festival.month
            && date.day <= this_year_spring_festival.day)
    {
        this_year_spring_festival.get_days_from_begins() - date.get_days_from_begins() - 1
    } else {
        let next_year_spring_festival = Date::get_the_year_spring_festival(date.year + 1);
        next_year_spring_festival.get_days_from_begins() + days_left_this_year - 1
    };
    format!("{week},{days_left_this_year},{spring_days}")
}

struct Date {
    year: i32,
    month: i32,
    day: i32,
}

impl Date {
    fn is_leap_year(&self) -> bool {
        (self.year % 4 == 0 && self.year % 100 != 0) || self.year % 400 == 0
    }

    fn get_days_by_month(&self, month: i32) -> i32 {
        match month {
            1 | 3 | 5 | 7 | 8 | 10 | 12 => 31,
            4 | 6 | 9 | 11 => 30,
            2 => {
                if self.is_leap_year() {
                    29
                } else {
                    28
                }
            }
            _ => panic!("Invalid month"),
        }
    }

    fn get_days_from_begins(&self) -> i32 {
        let mut days = 0;
        for i in 1..self.month {
            days += self.get_days_by_month(i);
        }
        days + self.day
    }

    fn get_the_week(&self) -> i32 {
        let next_year = Self::get_the_year_first_week_first_day_date(self.year + 1);
        if self.month == 12 && self.day >= next_year.day {
            return 1;
        }
        let this_year = Self::get_the_year_first_week_first_day_date(self.year);
        let mut days = 0;
        if this_year.year < self.year {
            let remain_days = Self::get_days_before_end(&this_year) + 1;
            days = self.get_days_from_begins() + remain_days;
        } else {
            let first_days = Self::get_days_from_begins(&this_year);
            days = self.get_days_from_begins() - first_days + 1;
        }

        if days % 7 == 0 {
            days / 7
        } else {
            days / 7 + 1
        }
    }

    fn get_days_before_end(&self) -> i32 {
        if self.is_leap_year() {
            366 - self.get_days_from_begins()
        } else {
            365 - self.get_days_from_begins()
        }
    }

    fn get_the_year_spring_festival(year: i32) -> Self {
        match year {
            2012 => Date {
                year: 2012,
                month: 1,
                day: 23,
            },
            2013 => Date {
                year: 2013,
                month: 2,
                day: 10,
            },
            2014 => Date {
                year: 2014,
                month: 1,
                day: 31,
            },
            2015 => Date {
                year: 2015,
                month: 2,
                day: 19,
            },
            2016 => Date {
                year: 2016,
                month: 2,
                day: 8,
            },
            2017 => Date {
                year: 2017,
                month: 1,
                day: 28,
            },
            2018 => Date {
                year: 2018,
                month: 2,
                day: 16,
            },
            2019 => Date {
                year: 2019,
                month: 2,
                day: 5,
            },
            2020 => Date {
                year: 2020,
                month: 1,
                day: 25,
            },
            2021 => Date {
                year: 2021,
                month: 2,
                day: 12,
            },
            2022 => Date {
                year: 2022,
                month: 2,
                day: 1,
            },
            2023 => Date {
                year: 2023,
                month: 1,
                day: 22,
            },
            2024 => Date {
                year: 2024,
                month: 2,
                day: 10,
            },
            2025 => Date {
                year: 2025,
                month: 1,
                day: 29,
            },
            2026 => Date {
                year: 2026,
                month: 2,
                day: 17,
            },
            _ => Date {
                year: 0,
                month: 0,
                day: 0,
            },
        }
    }

    fn get_the_year_first_week_first_day_date(year: i32) -> Self {
        match year {
            2012 => Date {
                year: 2012,
                month: 1,
                day: 2,
            },
            2013 => Date {
                year: 2012,
                month: 12,
                day: 31,
            },
            2014 => Date {
                year: 2013,
                month: 12,
                day: 30,
            },
            2015 => Date {
                year: 2014,
                month: 12,
                day: 29,
            },
            2016 => Date {
                year: 2015,
                month: 12,
                day: 28,
            },
            2017 => Date {
                year: 2017,
                month: 1,
                day: 2,
            },
            2018 => Date {
                year: 2018,
                month: 1,
                day: 1,
            },
            2019 => Date {
                year: 2018,
                month: 12,
                day: 31,
            },
            2020 => Date {
                year: 2019,
                month: 12,
                day: 30,
            },
            2021 => Date {
                year: 2021,
                month: 1,
                day: 4,
            },
            2022 => Date {
                year: 2021,
                month: 12,
                day: 27,
            },
            2023 => Date {
                year: 2023,
                month: 1,
                day: 2,
            },
            2024 => Date {
                year: 2024,
                month: 1,
                day: 1,
            },
            2025 => Date {
                year: 2024,
                month: 12,
                day: 30,
            },
            _ => Date {
                year: 0,
                month: 0,
                day: 0,
            },
        }
    }
}

impl From<&str> for Date {
    fn from(value: &str) -> Self {
        let s: Vec<&str> = value.split("-").collect();
        Self {
            year: s[0].parse().unwrap(),
            month: s[1].parse().unwrap(),
            day: s[2].parse().unwrap(),
        }
    }
}
